package com.business.system.service.impl;

import java.util.List;
import java.util.Map;

import com.business.system.bean.ApplyBean;
import net.sf.rose.jdbc.service.Service;

import com.business.system.service.BrandService;
import com.business.system.util.DBTools;

/**
 * @author: xudy
 * @date: 2018/04/11 13:57
 * @description:
 */
@org.springframework.stereotype.Service
public class BrandServiceImpl implements BrandService {
    @Override
    public List<Map<String,Object>> getApplyBrand(Service service, int type) throws  Exception{
        String sql ="select t1.USER_ID,t2.BRAND_ID from apply t1 left join user_brand t2 on t1.ID=t2.APPLY_ID where t1.TYPE=? and APPLY_STATUS=2";
        return DBTools.getDataList(service,sql,type);
    }

    @Override
    public List<Map<String,Object>> getMyAllBrand(Service service,String userId) throws  Exception{
        StringBuilder sql = new StringBuilder();
        sql.append("select t1.USER_ID,t2.BRAND_ID,t3.BRAND_NAME from apply t1");
        sql.append(" left join user_brand t2 on t1.ID=t2.APPLY_ID");
        sql.append(" left join brand t3 on t2.brand_id=t3.id");
        sql.append(" where APPLY_STATUS=? and t1.PAY_STATUS=? and t1.user_id=? and t1.TYPE=2");
        return DBTools.getDataList(service,sql.toString(), ApplyBean.APPLY_PASS,ApplyBean.PAY_IS_PASS,userId);
    }
}